package com.hengpeng.itfinbase.persist;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;

import com.hengpeng.common.web.annotation.HtmlInput;
import com.hengpeng.common.web.annotation.HtmlInputPattern;
import com.hengpeng.common.web.annotation.HtmlInputType;
import com.hengpeng.itfinbase.idAssign.AbstractAssign18IdEntity;

/**
 * <pre>
 * 邮件记录信息
 * </pre>
 * @author linriqing
 * @version 1.0, 2010-7-19
 */
@Entity
public class EmailLog extends AbstractAssign18IdEntity
{
	/**
	 * <pre>
	 * 邮件状态
	 * </pre>
	 * @author linriqing
	 * @version 1.0, 2010-7-19
	 */
	public static enum EmailState
	{
		NOTSEND("等待发送"), SENDED("已发送"), SENDING("正在发送");

		private String text;

		EmailState(String text)
		{
			this.text = text;
		}

		public String getText()
		{
			return text;
		}

		public void setText(String text)
		{
			this.text = text;
		}
	}

	/**
	 * <pre>
	 * 邮件记录类型
	 * </pre>
	 * @author linriqing
	 * @version 1.0, 2010-7-19
	 */
	public static enum EmailType
	{
		GETPWD("找回密码"), NORMAL("普通"), NOTIFY("通知"), PROMOTION("促销"), REGISTER("注册激活"), SUBSCRIBE(
				"邮件订阅激活"), VALIDEMAIL("邮箱验证"), WARNING("告警");

		private String text;

		EmailType(String text)
		{
			this.text = text;
		}

		public String getText()
		{
			return text;
		}

		public void setText(String text)
		{
			this.text = text;
		}
	}

	private static final long serialVersionUID = 3742228382782423527L;

	@HtmlInput(label = "内容", type = HtmlInputType.TEXT, index = 8, nullable = true)
	@Column(length = 5000)
	private String content;

	@HtmlInput(label = "邮箱", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.EMAIL, index = 2, nullable = false)
	private String email;

	@HtmlInput(label = "重发次数", type = HtmlInputType.TEXT, index = 4, nullable = true)
	private int retryCount;

	/**
	 * 发送级别值越大,越优先
	 */
	@HtmlInput(label = "级别", type = HtmlInputType.TEXT, index = 2, nullable = true)
	private int sendLevel;

	@HtmlInput(label = "发送时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.DATETIME, format = "yyyy-MM-dd HH:mm", index = 6, nullable = false)
	private Date sendTime;

	@HtmlInput(label = "发送人", type = HtmlInputType.HIDDEN, index = 10, nullable = true)
	@Column(length = 30)
	private String sendUserName;

	@HtmlInput(label = "状态", type = HtmlInputType.SELECT, index = 5, nullable = false, labelProperty = "text")
	@Column(length = 20)
	@Enumerated(javax.persistence.EnumType.STRING)
	private EmailState state;

	@HtmlInput(label = "成功时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.DATETIME, format = "yyyy-MM-dd HH:mm", index = 7, nullable = true)
	private Date successTime;

	@HtmlInput(label = "主题", type = HtmlInputType.TEXT, index = 3, nullable = false)
	private String title;

	@HtmlInput(label = "类型", type = HtmlInputType.SELECT, index = 1, nullable = false, labelProperty = "text")
	@Column(length = 20)
	@Enumerated(javax.persistence.EnumType.STRING)
	private EmailType type;

	@HtmlInput(label = "用户名", type = HtmlInputType.TEXT, index = 1, nullable = false)
	private String username;

	public String getContent()
	{
		return content;
	}

	public String getEmail()
	{
		return email;
	}

	public int getRetryCount()
	{
		return retryCount;
	}

	public int getSendLevel()
	{
		return sendLevel;
	}

	public Date getSendTime()
	{
		return sendTime;
	}

	public String getSendUserName()
	{
		return sendUserName;
	}

	public EmailState getState()
	{
		return state;
	}

	public Date getSuccessTime()
	{
		return successTime;
	}

	public String getTitle()
	{
		return title;
	}

	public EmailType getType()
	{
		return type;
	}

	public String getUsername()
	{
		return username;
	}

	public void setContent(String content)
	{
		this.content = content;
	}

	public void setEmail(String email)
	{
		this.email = email;
	}

	public void setRetryCount(int retryCount)
	{
		this.retryCount = retryCount;
	}

	public void setSendLevel(int sendLevel)
	{
		this.sendLevel = sendLevel;
	}

	public void setSendTime(Date sendTime)
	{
		this.sendTime = sendTime;
	}

	public void setSendUserName(String sendUserName)
	{
		this.sendUserName = sendUserName;
	}

	public void setState(EmailState state)
	{
		this.state = state;
	}

	public void setSuccessTime(Date successTime)
	{
		this.successTime = successTime;
	}

	public void setTitle(String title)
	{
		this.title = title;
	}

	public void setType(EmailType type)
	{
		this.type = type;
	}

	public void setUsername(String username)
	{
		this.username = username;
	}

}